package com.eastfair.api;

import com.eastfair.core.base.R;
import com.eastfair.imaster.dto.CollectionDTO;
import com.eastfair.imaster.dto.CollectionQuery;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Set;

/**
 * @ClassName InteractionServiceFeign
 * @Description TODO
 * @Author liuxiaobai
 * @Date 2021/9/1 3:39 下午
 * @Version 1.0
 */
@FeignClient(value = "interaction")
public interface InteractionServiceFeign {

    /**
     * 收藏
     * 未收藏时添加收藏记录，已收藏时取消收藏
     * @param collectionDTO subjectType、subjectId
     * @return 成功true 失败false
     */
    @PostMapping("/interaction/collection/collect")
    R<Boolean> collect(@RequestBody CollectionDTO collectionDTO);

    /**
     * 校验是否收藏
     * @param query subjectType、subjectId
     * @return 已收藏ture/未收藏false
     */
    @PostMapping("/interaction/collection/check")
    R<Boolean> checkCollect(@RequestBody CollectionQuery query);

    /**
     * 校验有没有收藏过 并返回收藏数
     * @param query type、id
     * @return collectionDTO{isCollect,num}
     */
    @PostMapping("/interaction/collectioncheckWithNum")
    R<CollectionDTO> checkCollectWithNum(@RequestBody CollectionQuery query);

    /**
     * 批量校验是否收藏
     * @param query subjectType、subjectIds
     * @return 已收藏的内容ID集合 此处用set 因为组装数据频繁调用contains
     */
    @PostMapping("/interaction/collection/checkBatch")
    R<Set<Long>> checkCollectBatch(@RequestBody CollectionQuery query);

    /**
     * 批量校验是否收藏过 并返回收藏数
     * @param query type、id
     * @return key-subjectId value-collectionDTO{isCollect,num}
     */
    @PostMapping("/interaction/collection/checkBatchWithNum")
    R<Map<Long,CollectionDTO>> checkCollectBatchWithNum(@RequestBody CollectionQuery query);

}
